.\" Copyright (c) 2016 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
.TH TMPFS 5 2016-11-07 "Linux" "Linux Programmer's Manual"
.SH NAME
tmpfs \- a virtual memory filesystem
.SH DESCRIPTION
The
.B tmpfs
facility allows the creation of filesystems whose contents reside
in virtual memory.
Since the files on such filesystems typically reside in RAM,
file access is extremely fast.

The filesystem is automatically created when mounting
a filesystem with the type
.BR tmpfs
via a command such as the following:

    $ sudo mount \-t tmpfs -o size=10M tmpfs /mnt/mytmpfs

A
.B tmpfs
filesystem has the following properties:
.IP * 3
The filesystem can employ swap space when physical memory pressure
demands it.
.IP *
The
.I size
option can be used to specify an upper limit on the size of the filesystem.
(The default size is half of the available RAM size.)
The filesystem consumes only as much physical memory and swap space
as is required to store the current contents of the filesystem.
.IP *
During a remount operation
.RI ( "mount\ \-o\ remount" ),
the filesystem size can be changed
(without losing the existing contents of the filesystem).
.PP
If a
.B tmpfs
filesystem is unmounted, its contents are discarded (lost).
.SH VERSIONS
The
.B tmpfs
facility was added in Linux 2.4, as a successor to the older
.B ramfs
facility, which did not provide limit checking or
allow for the use of swap space.
.SH NOTES
For a description of the mount options that may be employed when mounting a
.B tmpfs
filesystem, see
.BR mount (8).

In order to for user-space tools and applications to create
.B tmpfs
filesystems, the kernel must be configured with the
.B CONFIG_TMPFS
option.

An internal shared memory filesystem is used for
System V shared memory
.BR (shmget (2))
and shared anonymous mappings
.RB ( mmap (2)
with the
.B MAP_SHARED
and
.BR MAP_ANONYMOUS
flags).
This filesystem is available regardless of whether
the kernel was configured with the
.B CONFIG_TMPFS
option.

A
.B tmpfs
filesystem mounted at
.IR /dev/shm
as used for the implementation of POSIX shared memory
.RB ( shm_overview (7))
and POSIX semaphores
.RB ( sem_overview (7)).

The amount of memory consumed by all
.B tmpfs
filesystems is shown in the
.I Shmem
field of
.IR /proc/meminfo
and in the
.I shared
field displayed by
.BR free (1).

The
.B tmpfs
facility was formerly called
.BR shmfs .
.SH SEE ALSO
.BR df (1),
.BR du (1),
.BR mount (8)
.PP
The kernel source file
.IR Documentation/filesystems/tmpfs.txt .
